diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2023-02-19 14:08:33 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2023-02-19 14:08:33 +0100 |
| commit | 54bbc06bd84437c6b38e2f6c57060f21a8318720 (patch) | |
| tree | a0f9beb425829e304cdf239709e7d23a13b0fcc8 /src/routes/[lang=lang] | |
| parent | 06ce8fbab52c5c25a67a1518f1888b083b5edde3 (diff) | |
| download | auroraklinikken.no-54bbc06bd84437c6b38e2f6c57060f21a8318720.tar.xz auroraklinikken.no-54bbc06bd84437c6b38e2f6c57060f21a8318720.zip | |
.
Diffstat (limited to 'src/routes/[lang=lang]')
| -rw-r--r-- | src/routes/[lang=lang]/+page.server.ts | 54 | ||||
| -rw-r--r-- | src/routes/[lang=lang]/+page.svelte | 2 | ||||
| -rw-r--r-- | src/routes/[lang=lang]/+page.ts | 30 | ||||
| -rw-r--r-- | src/routes/[lang=lang]/sections/products.svelte | 17 |
4 files changed, 59 insertions, 44 deletions
diff --git a/src/routes/[lang=lang]/+page.server.ts b/src/routes/[lang=lang]/+page.server.ts index a647cfe..c2284ee 100644 --- a/src/routes/[lang=lang]/+page.server.ts +++ b/src/routes/[lang=lang]/+page.server.ts @@ -1,29 +1,31 @@ -import { sanity } from '$lib/sanity-client'; -import type { PageServerLoad } from './$types'; +import { sanity } from "$lib/sanity-client"; +import type { PageServerLoad } from "./$types"; import groq from "groq"; -import type { ContactModel } from './sections/contact.svelte'; -import { fromLocalizedString } from '$lib/utils'; -import type { HeroModel } from './sections/hero.svelte'; -import type { DescriptionModel } from './sections/description.svelte'; +import type { ContactModel } from "./sections/contact.svelte"; +import { fromLocalizedString } from "$lib/utils"; +import type { HeroModel } from "./sections/hero.svelte"; +import type { DescriptionModel } from "./sections/description.svelte"; export const load = (async ({ locals }) => { - const contactSection = await sanity.fetch(groq`*[_type == "contact"][0]`); - const heroSection = await sanity.fetch(groq`*[_type == "hero"][0]`); - const descriptionSection = await sanity.fetch(groq`*[_type == "description"][0]`); - return { - contact: { - phone: fromLocalizedString(contactSection.phone, locals.locale), - email: fromLocalizedString(contactSection.email, locals.locale), - phoneHours: fromLocalizedString(contactSection.phoneHours, locals.locale), - addressLines: contactSection.addressLines.map((el: string | object) => fromLocalizedString(el, locals.locale)), - } as ContactModel, - hero: { - title: heroSection.title, - content: heroSection.content - } as HeroModel, - description: { - title: descriptionSection.title, - content: descriptionSection.content - } as DescriptionModel - }; -}) satisfies PageServerLoad;
\ No newline at end of file + const contactSection = await sanity.fetch(groq`*[_type == "contact"][0]`); + const heroSection = await sanity.fetch(groq`*[_type == "hero"][0]`); + const descriptionSection = await sanity.fetch(groq`*[_type == "description"][0]`); + const products = await sanity.fetch(groq`*[_type == "product"]`); + return { + contact: { + phone: fromLocalizedString(contactSection.phone, locals.locale), + email: fromLocalizedString(contactSection.email, locals.locale), + phoneHours: fromLocalizedString(contactSection.phoneHours, locals.locale), + addressLines: contactSection.addressLines.map((el: string | object) => fromLocalizedString(el, locals.locale)), + } as ContactModel, + hero: { + title: heroSection.title, + content: heroSection.content, + } as HeroModel, + description: { + title: descriptionSection.title, + content: descriptionSection.content, + } as DescriptionModel, + products: products + }; +}) satisfies PageServerLoad; diff --git a/src/routes/[lang=lang]/+page.svelte b/src/routes/[lang=lang]/+page.svelte index 325f085..f2028c6 100644 --- a/src/routes/[lang=lang]/+page.svelte +++ b/src/routes/[lang=lang]/+page.svelte @@ -12,4 +12,4 @@ <Hero model={data.hero} /> <Description model={data.description} /> <Contact model={data.contact} /> -<Products model={data.products} />
\ No newline at end of file +<Products model={data.products} /> diff --git a/src/routes/[lang=lang]/+page.ts b/src/routes/[lang=lang]/+page.ts index 1ef0b57..fa95472 100644 --- a/src/routes/[lang=lang]/+page.ts +++ b/src/routes/[lang=lang]/+page.ts @@ -1,18 +1,18 @@ -import type { PageLoad } from './$types'; -import LL, { setLocale } from '$i18n/i18n-svelte' -import { get } from 'svelte/store' +import type { PageLoad } from "./$types"; +import LL, { setLocale } from "$i18n/i18n-svelte"; +import { get } from "svelte/store"; export const load = (async ({ parent, data }) => { - // wait for `+layout.ts` to load dictionary and pass locale information - const { locale } = await parent() + // wait for `+layout.ts` to load dictionary and pass locale information + const { locale } = await parent(); - // if you need to output a localized string in a `load` function, - // you always need to call `setLocale` right before you access the `LL` store - setLocale(locale) - // get the translation functions value from the store - const $LL = get(LL) - return { - title: $LL.homeTitle(), - ...data - } -}) satisfies PageLoad;
\ No newline at end of file + // if you need to output a localized string in a `load` function, + // you always need to call `setLocale` right before you access the `LL` store + setLocale(locale); + // get the translation functions value from the store + const $LL = get(LL); + return { + title: $LL.homeTitle(), + ...data, + }; +}) satisfies PageLoad; diff --git a/src/routes/[lang=lang]/sections/products.svelte b/src/routes/[lang=lang]/sections/products.svelte index 4e10b6f..816e276 100644 --- a/src/routes/[lang=lang]/sections/products.svelte +++ b/src/routes/[lang=lang]/sections/products.svelte @@ -13,6 +13,8 @@ </script> <script lang="ts"> + import CardV4 from "$components/card-v4.svelte"; + export let model: ProductsModel; let visible = true; @@ -24,5 +26,16 @@ </script> {#if visible} - -{/if}
\ No newline at end of file + <div class="wrapper"> + {#each model.products as product} + <CardV4 description={product.description} title={product.title} /> + {/each} + </div> +{/if} + +<style lang="postcss"> + .wrapper { + display: grid; + grid-template-columns: repeat(50%); + } +</style> |
